<?php

use yii\db\Migration;

class m171201_024242_alter_student_check extends Migration
{
    private function createDbs(){
        $dbs = [];
        $dbs_info =\Yii::$app->params['db'];
        foreach($dbs_info as $k=>$v){
            $dbs[$k] = \Yii::createObject($v);
        }
        return $dbs;
    }
    public function safeUp()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->addColumn('{{%student_check}}', 'is_makeup', $this->smallInteger(1)->defaultValue(0)->comment('是否补课 0 否 1 是'));
            $this->addColumn('{{%student_check}}', 'remarks', $this->string(225)->defaultValue(null)->comment('备注'));
        }

    }

    public function safeDown()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->dropColumn('{{%student_check}}', 'is_makeup');
            $this->dropColumn('{{%student_check}}', 'remarks');
        }
    }
}
